/*
 * FrameBuffer.hpp
 *
 *  Created on: 16.06.2011
 *      Author: kirill
 */

#include "../BasicTypes.h"

#ifndef FRAMEBUFFER_HPP_
#define FRAMEBUFFER_HPP_

class IRenderBuffer
{
protected:
	GLuint RenderBufferName;
public:
	IRenderBuffer(){};
	virtual ~IRenderBuffer(){};
	virtual GLuint GetBufferName() const { return RenderBufferName; };
	virtual void TuneRenderBuffer( const GLenum format, const GLsizei width, const GLsizei height ) = 0;
	virtual void UpdateBuffer() = 0;
};

class CColorRenderBuffer : public IRenderBuffer
{
public:
	CColorRenderBuffer();
	~CColorRenderBuffer(){  glDeleteRenderbuffers(  1, &RenderBufferName ); };
	virtual void TuneRenderBuffer( const GLenum format, const GLsizei width, const GLsizei height );
	virtual void UpdateBuffer(){};
};

class CTextureRenderBuffer : public IRenderBuffer
{
public:
	CTextureRenderBuffer();
	virtual ~CTextureRenderBuffer(){};
	virtual void TuneRenderBuffer( const GLenum format, const GLsizei width, const GLsizei height );
	virtual void UpdateBuffer();
};

//----------------------------

class CFrameBuffer
{
private:
	GLuint FrameBufferName;
public:
	CFrameBuffer();
	virtual ~CFrameBuffer();
    virtual void SetRenderTarget( const GLenum Target, const CColorRenderBuffer *RenderTarget );
    virtual void SetRenderTarget( const GLenum Target, const CTextureRenderBuffer *RenderTarget );
    virtual void BindFrameBuffer( const bool Bind );
    virtual bool CheckFrameBuffer();
};

#endif /* FRAMEBUFFER_HPP_ */
